//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package ui;

import javax.swing.JTextPane;
import javax.swing.text.BoxView;
import javax.swing.text.ComponentView;
import javax.swing.text.Element;
import javax.swing.text.IconView;
import javax.swing.text.LabelView;
import javax.swing.text.ParagraphView;
import javax.swing.text.StyledEditorKit;
import javax.swing.text.View;
import javax.swing.text.ViewFactory;

public class MyTextPane extends JTextPane {
    public MyTextPane() {
        this.setEditorKit(new MyTextPane.WrapEditorKit());
    }

    class WrapLabelView extends LabelView {
        public WrapLabelView(Element elem) {
            super(elem);
        }

        public float getMinimumSpan(int axis) {
            switch(axis) {
                case 0:
                    return 0.0F;
                case 1:
                    return super.getMinimumSpan(axis);
                default:
                    throw new IllegalArgumentException("Invalid axis: " + axis);
            }
        }
    }

    class WrapColumnFactory implements ViewFactory {
        WrapColumnFactory() {
        }

        public View create(Element elem) {
            String kind = elem.getName();
            if (kind != null) {
                if (kind.equals("content")) {
                    return MyTextPane.this.new WrapLabelView(elem);
                }

                if (kind.equals("paragraph")) {
                    return new ParagraphView(elem);
                }

                if (kind.equals("section")) {
                    return new BoxView(elem, 1);
                }

                if (kind.equals("component")) {
                    return new ComponentView(elem);
                }

                if (kind.equals("icon")) {
                    return new IconView(elem);
                }
            }

            return new LabelView(elem);
        }
    }

    class WrapEditorKit extends StyledEditorKit {
        ViewFactory defaultFactory = MyTextPane.this.new WrapColumnFactory();

        WrapEditorKit() {
        }

        public ViewFactory getViewFactory() {
            return this.defaultFactory;
        }
    }
}
